<?php

class VersionController extends Controller
{
	/**
	 * Declares class-based actions.
	 */
	public function actions()
	{
		return array(
		);
	}


    /**
     * 获得更新的版本数据
     * @param $versionNo
     */
    public function actionGetUpdateData($versionNo=0) {
        $local = CommonUtils::getLocal();
        if ($local=='zn') {
            $versionPath = _VERSION_DATAPAK_PATH_ZN;
        } else {
            $versionPath = _VERSION_DATAPAK_PATH_EN;
        }

        $resultArr = array();
        $resultArr['version'] = $versionNo;
        $result = Version::model()->find();
        if(!empty($result))
        {
           $curv = $result->toArray()['versionNo'];
           if ($curv>$versionNo) {
               $resultArr['version'] = $curv;
               $sqlarr = array();
               for($index=$versionNo+1;$index<=$curv;$index++) {
                   $filename = $versionPath.$index.'_version.txt';
                   if (!file_exists($filename)) {
                       $resultArr['version'] = $index-1;
                       echoToMobile($resultArr);
                       return;
                   }
                   $arrf = file($filename);
                   $sqlarr = array_merge($sqlarr,$arrf);
               }
               $resultArr['sqls'] = $sqlarr;
           }
        }
        echoToMobile($resultArr);
    }
}